#!/usr/bin/env python3
# -*- coding:utf-8 -*-
"""
@author:shengwei
@file:usually_use_func.py
@time:2018/2/25 002515:18
"""
from datetime import datetime, timedelta

time_now = datetime.now()
dt = datetime(2017, 1, 22, 12, 20)
timestamp_py = dt.timestamp()
# 2018-02-25 15:26:49.409601 time_now
# 2017-01-22 12:20:00 指定时间
# 1485058800.0 指定时间时间戳
# 2017-01-22 12:20:00 将时间戳转换为时间(本地时间)
#  2017-01-22 04:20:00 将时间戳转换为时间(UTC时间)
# print(time_now, dt, timestamp_py, datetime.fromtimestamp(timestamp_py), datetime.utcfromtimestamp(timestamp_py))
#
# # 很多时候，用户输入的日期和时间是字符串，要处理日期和时间，首先必须把str转换为datetime
# cday = datetime.strptime('2015-6-1 18:19:59', '%Y-%m-%d %H:%M:%S')
# print(cday)
#
# # 如果已经有了datetime对象，要把它格式化为字符串显示给用户
# now = datetime.now()
# print(now.strftime('%Y-%m-%d %H:%M'))

#datetime加减
now = datetime.now()
caculate = now + timedelta(days=1, hours=12)
print(now, caculate)
